home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 142
/
Gekkan Dennou Club - 2000.3 Vol. 142 (Japan).7z
/
Gekkan Dennou Club - 2000.3 Vol. 142 (Japan) (Track 1).bin
/
tools
/
s_tool
/
str.c
< prev
next >
Wrap
Text File
|
1999-06-08
|
12KB
|
578 lines
#include "JX250.H"
#include <sys\iocs.h>
#include <sys\dos.h>
#include <sys\scsi.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <_tnb.c>
/******************************************************
数値プリント(ito3a付き)
******************************************************/
void p_12_ito3a(x,y,d)
int x,y,d;
{
char buf[16];
ito3a(d,buf);
p_12W(x,y,buf);
}
/******************************************************
数値プリント(ito4a付き)
******************************************************/
void p_12_ito4a(x,y,d)
int x,y,d;
{
char buf[16];
ito4a(d,buf);
p_12W(x,y,buf);
}
/******************************************************
数値プリント(sprintf付き)
******************************************************/
void p_12_sprintf(x,y,str,d1,d2,d3)
int x,y,d1,d2,d3;
UNchar *str;
{
char buf[100];
sprintf(buf,str,d1,d2,d3);
p_12W(x,y,buf);
}
/******************************************************
数値プリント(sprintf付き)
******************************************************/
void p_12_sprintf_double(x,y,str,d1,d2)
int x,y;
double d1,d2;
UNchar *str;
{
char buf[100];
sprintf(buf,str,d1,d2);
p_12W(x,y,buf);
}
/*****************************************************
背景(白)付き12dot 文字列表示
*****************************************************/
int p_12W(x,y,st)
int x,y;
UNchar *st;
{
int l;
struct _fillptr PP;
l=jstrlen_(st);
PP.x1=x;
PP.y1=y;
PP.x2=x+l*6-1;
PP.y2=y+12-1;
PP.color=PalTable[15];
// CRTVDISP();
_iocs_fill(&PP);
return( p_12H(x,y,st) );
}
/*****************************************************
12ドット文プリント
*****************************************************/
int p_12H(x,y,st)
int x,y;
UNchar *st;
{
int l;
int ssp;
struct FNTBUF FB;
ssp=_iocs_b_super(0);
GGCHAR_COLOR1=RGB(1,1,1);
while( l=*(st++) ){
if ( ZenChk(l) )
l=(l*0x100)+(*st++);
FNTGET12(l,&FB);
GGCHAR_S(VADDS(0,x,y),&FB);
x+=FB.xl;
}
if ( ssp>=0 )
_iocs_b_super(ssp);
return(0);
}
/*****************************************************
影付き16ドット文プリント
*****************************************************/
int p_16K(x,y,st)
int x,y;
UNchar *st;
{
int l;
int ssp;
struct _fntbuf FB;
ssp=_iocs_b_super(0);
while( l=*(st++) ){
if ( ZenChk(l) )
l=(l*0x100)+(*st++);
//_iocs_fntget(8,l,&FB);
FNTGET(8,l,&FB);
GGCHAR_COLOR1=RGB(1,1,1);
GGCHAR_S(VADDS(0,x+1,y+1),(void*)&FB);
GGCHAR_COLOR1=RGB(31,31,31);
GGCHAR_S(VADDS(0,x,y),(void*)&FB);
x+=FB.xl;
}
if ( ssp>=0 )
_iocs_b_super(ssp);
GGCHAR_COLOR1=RGB(1,1,1);
return(0);
}
/*****************************************************
影付き12ドット文プリント
*****************************************************/
int p_12K(x,y,st)
int x,y;
UNchar *st;
{
int l;
int ssp;
struct FNTBUF FB;
ssp=_iocs_b_super(0);
while( l=*(st++) ){
if ( ZenChk(l) )
l=(l*0x100)+(*st++);
FNTGET12(l,&FB);
//_iocs_fntget(6,l,&FB);
GGCHAR_COLOR1=RGB(31,31,31);
GGCHAR_S(VADDS(0,x+1,y+1),&FB);
GGCHAR_COLOR1=0x4210;
GGCHAR_S(VADDS(0,x,y),&FB);
x+=FB.xl;
}
if ( ssp>=0 )
_iocs_b_super(ssp);
GGCHAR_COLOR1=RGB(31,31,31);
return(0);
}
/*****************************************************
12ドット文テキストプリント
*****************************************************/
int text_12H(x,y,st)
int x,y;
UNchar *st;
{
int o,l;
int ssp;
struct FNTBUF FB;
ssp=_iocs_b_super(0);
o=*(UNshort*)0xe8002a;
*(UNshort*)0xe8002a=0x00;
while( l=*(st++) ){
if ( ZenChk(l) )
l=(l*0x100)+(*st++);
FNTGET12(l,&FB);
if ( FB.xl==6 )
TXHMOJI_S(x,y,&FB);
else TXZMOJI_S(x,y,&FB);
x+=FB.xl;
}
*(UNshort*)0xe8002a=o;
if ( ssp>=0 )
_iocs_b_super(ssp);
return(0);
}
/*************************************************
intを2文字列に
*************************************************/
void ito2a(i,st)
int i;
UNchar *st;
{
int k;
k=DIVU(i,10); *st++=( k )?k+'0':' ';
*st++=MODU(i,10)+'0';
*st =0;
}
/*************************************************
intを3文字列に
*************************************************/
void ito3a(i,st)
int i;
UNchar *st;
{
int l,k;
l=DIVU(i,100); *st++=( l )?l+'0':' ';
k=DIVU(i,10);k-=MULU(l,10); *st++=( k )?k+'0':( l )?'0':' ';
*st++=MODU(i,10)+'0';
*st =0;
}
/*************************************************
intを4文字列に
*************************************************/
void ito4a(i,st)
int i;
UNchar *st;
{
int j,l,k;
j=DIVU(i,1000); *st++=( j )?j+'0':' ';
l=DIVU(i,100); l=MODU(l,10); *st++=( l )?l+'0':( j )?'0':' ';
k=DIVU(i,10); k=MODU(k,10); *st++=( k )?k+'0':( l )?'0':( j )?'0':' ';
*st++=MODU(i,10)+'0';
*st =0;
}
/*************************************************
intを5文字列に
*************************************************/
void ito5a(i,st)
int i;
UNchar *st;
{
int a,j,l,k;
a=DIVU(i,10000); *st++=( a )?a+'0':' ';
j=DIVU(i,1000);j=MODU(j,10); *st++=( j )?j+'0':( a )?'0':' ';
l=DIVU(i,100); l=MODU(l,10); *st++=( l )?l+'0':( j )?'0':( a )?'0':' ';
k=DIVU(i,10); k=MODU(k,10); *st++=( k )?k+'0':( l )?'0':( j )?'0':( a )?'0':' ';
*st++=MODU(i,10)+'0';
*st =0;
}
/*************************************************
漢字を含む文字列の複製
*************************************************/
char *jstrcpy(sou,des)
UNchar *sou,*des;
{
UNchar c;
UNchar *r=sou;
while( c=(*(sou++)=*(des++)) )
if ( ZenChk(c) )
*(sou++)=*(des++);
return(r);
}
/*************************************************
漢字を含む文字列の連結
*************************************************/
char *jstrcat(sou,des)
UNchar *sou,*des;
{
UNchar c;
UNchar *r=sou;
while( c=*(sou) ){
sou++;
if ( ZenChk(c) )
sou++;
}
while( c=(*(sou++)=*(des++)) )
if ( ZenChk(c) )
*(sou++)=*(des++);
return(r);
}
/*************************************************
漢字を含む文字列長(byte)
全角は2文字分
*************************************************/
int jstrlen(st)
UNchar *st;
{
int l,c;
l=0;
while( c=*(st++) ){
l++;
if ( ZenChk(c) ){
l++; st++;
}
}
return(l);
}
/*************************************************
漢字を含む文字列長(文字幅)
全角は2文字分
*************************************************/
int jstrlen_(st)
UNchar *st;
{
int l,c;
l=0;
while( c=*(st++) ){
l++;
if ( ZenChk(c) ){
if ( c>0x80 && c<0xF0 )
l++;
st++;
}
}
return(l);
}
/*************************************************
漢字を含む文字列長(文字幅,TAB考慮)
全角は2文字分
*************************************************/
int jstrlen_tb(st)
UNchar *st;
{
int l,c;
l=0;
while( c=*(st++) ){
if ( c==0x0d || c==0x0a || c==0x1a )
break;
if ( c=='\t' ){
do{
l++;
} while ( l % 8 );
continue;
}
l++;
if ( ZenChk(c) ){
if ( c>0x80 && c<0xF0 )
l++;
st++;
}
}
return(l);
}
/*************************************************
漢字を含む文字列の半角英字小文字を大文字にします
全角は2文字分
*************************************************/
int jstrupr(st)
UNchar *st;
{
int c;
UNchar *r=st;
while( c=*st ){
if ( ZenChk(c) )
st++;
elif ( c>=0x61 && c<=0x7A )
*st=c-0x20;
st++;
}
return((int)r);
}
/*************************************************
漢字を含む文字列の比較をします
(半角英字は大文字小文字区別されません))
*************************************************/
int jstrcmpi(st1,st2)
UNchar *st1,*st2;
{
int c,c1,c2;
do {
c1=*st1++;
if ( ZenChk(c1) ){
/*[1]は全角*/
c2=*st2++;
if ( c1<c2 ) return(-1);
if ( c1>c2 ) return(1);
if ( ZenChk(c2)==0 )
return(1); /*[2]は全角じゃない*/
c=*st1++;
c2=*st2++;
if ( c<c2 ) return(-1);
if ( c>c2 ) return(1);
c1=c1*0x100+c;
} else {
/*[1]は半角*/
c2=*st2++;
if ( ZenChk(c2)!=0 )
return(-1); /*[2]は全角だ*/
if ( c1>='A' && c1<='Z' ) c1|=0x20;
if ( c2>='A' && c2<='Z' ) c2|=0x20;
if ( c1<c2 ) return(-1);
if ( c1>c2 ) return(1);
}
} while( c1!=0 );
return(0);
}
/**************************************************
全角チェック)
[戻り値] 0 : 半角
1 : 全角
**************************************************/
int ZenChk(c)
int c;
{
return( (c>=0x80 && c<=0x9f) || c>=0xE0 );
}
/*************************************************
ダイアログ表示
[in] *s1,*s2,*s3 表示文字列
md=-1; 表示を消す
md= 0; 待ちなし
md= 1; 確認
md= 2; 選択
[out] md==2 の場合のみ。
0 ; 選択
-1 ; 中止
*************************************************/
int Dialog(s1,s2,s3,md)
UNchar *s1,*s2,*s3;
int md;
{
int i,b,r;
int xx,yy;
int ssp;
extern UNchar diabak[165*205*2]; // ダイアログ用のバッファ
struct _fillptr PP;
struct _getptr GP;
GP.buf_start=&diabak[0];
GP.buf_end=&diabak[165*205*2-1];
PP.x1 = GP.x1 = 2*16;
PP.y1 = GP.y1 = 10*16;
PP.x2 = GP.x2 = GP.x1+12*16+8;
PP.y2 = GP.y2 = GP.y1+10*16;
//--
if ( md<0 ){
// 消す(前に「待ちなし」を実行していること)
_iocs_putgrm( (void*)&GP );
return(0);
}
//-- 記憶
_iocs_getgrm( &GP );
//-- ベタ書く
PP.color=PalTable[14];
_iocs_fill(&PP);
//-- 枠(白)書く
PP.x1=2*16;
PP.y1=10*16;
PP.x2=PP.x1+1;
PP.y2=PP.y1+10*16;
PP.color=PalTable[15];
_iocs_fill(&PP);
PP.x2=PP.x1+12*16+8;
PP.y2=PP.y1+1;
_iocs_fill(&PP);
//-- 枠(影)書く
PP.x1=2*16+12*16+8-1;
PP.y1=10*16+1;
PP.x2=PP.x1+1;
PP.y2=PP.y1+10*16-1;
PP.color=PalTable[10];
_iocs_fill(&PP);
PP.x1=2*16+1;
PP.y1=10*16+10*16-1;
PP.x2=PP.x1+12*16+8-1;
PP.y2=PP.y1+1;
_iocs_fill(&PP);
//--
if ( s1!=0 )
p_12H(4*16,11*16,s1);
if ( s2!=0 )
p_12H(4*16,13*16,s2);
if ( s3!=0 )
p_12H(4*16,15*16,s3);
if ( md==0 )
return(0);
while( MS_LSW()!=0 || MS_RSW()!=0 );
ssp=_iocs_b_super(0);
if ( md==1 ){
// 確認のみ
GGSP16_64_S(TADDS(12,17),0x48);
GGSP16_64_S(TADDS(13,17),0x49);
GGSP16_64_S(TADDS(12,18),0x50);
GGSP16_64_S(TADDS(13,18),0x51);
/*
PP.x=12*16;
PP.y=17*16;
PP.x1=32*1;
PP.y1=32*1;
PP.vram_page=0x8003;
PP.fill_patn=0x0000;
_iocs_txfill(&PP);
*/
} else {
// 選択
GGSP16_64_S(TADDS(10,17),0x48);
GGSP16_64_S(TADDS(11,17),0x49);
GGSP16_64_S(TADDS(10,18),0x50);
GGSP16_64_S(TADDS(11,18),0x51);
GGSP16_64_S(TADDS(12,17),0x4a);
GGSP16_64_S(TADDS(13,17),0x4b);
GGSP16_64_S(TADDS(12,18),0x52);
GGSP16_64_S(TADDS(13,18),0x53);
/*
PP.x=10*16;
PP.y=17*16;
PP.x1=32*2;
PP.y1=32*1;
PP.vram_page=0x8003;
PP.fill_patn=0x0000;
_iocs_txfill(&PP);
*/
}
if ( ssp>0 )
_iocs_b_super(ssp);
//_iocs_sp_on();
MsPat(1);
for(;;){
do {
yy=( i=_iocs_ms_curgt() )&0xFFFF;
xx=i>>16;
//_iocs_sp_regst(0,bit(31),xx+16 ,yy+16 ,1,1);
if ( (_iocs_bitsns(3)&bit(5))!=0 )
break;
if ( (_iocs_bitsns(9)&bit(6))!=0 )
break;
if ( (_iocs_bitsns(1)&bit(0))!=0 )
break;
} while( MS_LSW()==0 && (b=MS_RSW())==0 );
if ( (_iocs_bitsns(3)&bit(5))!=0 || (_iocs_bitsns(9)&bit(6))!=0 ){
r=0;
while( (_iocs_bitsns(3)&bit(5))!=0 || (_iocs_bitsns(9)&bit(6))!=0 );
break;
}
if ( (_iocs_bitsns(1)&bit(0))!=0 ){
r=-1;
while( (_iocs_bitsns(1)&bit(0))!=0 );
break;
}
if ( b!=0 ){
if ( md==2 ){
r=-1;
break;
}
continue;
}
if ( yy<17*16 || yy>=19*16 )
continue;
if ( xx>=12*16 && xx<14*16 ){
if ( sxbotton(12*16,17*16,14*16-1,19*16-1,1)==0 ){
r=-1;
break;
}
} elif ( md==2 && xx>=10*16 && xx<12*16 ){
if ( sxbotton(10*16,17*16,12*16-1,19*16-1,1)==0 ){
r=0;
break;
}
}
}
_iocs_putgrm( (void*)&GP );
return(r);
}
/*************************************************
DUMP
*************************************************/
void dumps(bb,ll)
UNchar *bb;
int ll;
{
int i,j,m,n,c;
for(j=0;j<ll;j+=16){
for(i=0;i<16;i++){
n=j+i;
if ( n>=ll )
break;
printf("%02X ",bb[n]);
}
printf(" ");
for(i=0;i<16;i++){
n=j+i;
if ( n>=ll )
break;
c=bb[n];
if ( c<0x20 )
c='.';
else if ( c>=0x80 && c<=0x9F )
c='.';
else if ( c>=0xE0 )
c='.';
putchar(c);
}
printf("\n");
}
return;
}